package com.ruoyi.bigdata;

import com.ruoyi.common.core.controller.BaseController;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@RequestMapping("/batch")
public class ExportController extends BaseController {

    @Resource
    private HighPerformanceExcelExportService excelExportService;

    @PostMapping("/export")
    public void exportSysOperLog(HttpServletResponse response) throws IOException {
        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        response.setHeader("Content-Disposition", "attachment; filename=sysOperLog.xlsx");

        try {
            excelExportService.exportSysOperLogToExcel(1, 2000000, response.getOutputStream());
        } finally {
            response.getOutputStream().flush();
        }
    }

}
